﻿using System;
using System.Data;
using visinia.SmartEngine.Providers;

namespace SmartMenu.Providers
{
    public abstract partial class SmartMenuDataProvider
    {         
        #region INIT
        private static SmartMenuDataProvider _provider;
        private static object _lock = new object();

        public static SmartMenuDataProvider Provider
        {
            get { InternalInitialize(); return _provider; }
        }
        private static void InternalInitialize()
        {
            if (_provider == null)
            {
                lock (_lock)
                {
                    if (_provider == null)
                    {
                        _provider = (SmartMenuDataProvider)ProviderController.CreateDataProvider("SmartMenu");
                        if (_provider == null)
                            throw new Exception("Unable to load default SmartMenuDataProvider");
                    }
                }
            }
        }
        #endregion

        #region MENU
        public abstract IDataReader GetMenus();
        public abstract IDataReader AddMenu(string Name);
        public abstract void UpdateMenu(int MenuId, string Name);
        public abstract void DeleteMenu(int MenuId);

        public abstract IDataReader GetMenuItems();
        public abstract IDataReader AddMenuItem(int MenuId, int ParentId, string Title, string Url, int Order, bool Visible, string Image);
        public abstract void UpdateMenuItem(int MenuItemId, int MenuId, int ParentId, string Title, string Url, int Order, bool Visible, string Image);
        public abstract void DeleteMenuItem(int MenuItemId);
        #endregion
    }
}
